<template>
  <el-form class="add-event-activity-info" v-if="wbData">
    <dropdown-normal v-model="wbData.activityType" :valLists="GENERAL_ACTIVITY_TYPES" label="活动类型" @change="onUpdateWbComponent" ></dropdown-normal>
    <dropdown-normal v-model="wbData.jumpPopId" :valLists="pushPops()" label="跳转弹层" @change="onUpdateWbComponent"></dropdown-normal>
    <dropdown-normal v-model="wbData.jumpPageId" :valLists="pushPages()" label="跳转页面" @change="onUpdateWbComponent"></dropdown-normal>
    <textarea-normal label="获取活动信息需要的关联组件id" v-model="wbData.relateCompId" placeholder="$id$" @change="onUpdateWbComponent"></textarea-normal>
    <textarea-normal label="自定义数据" v-model="wbData.params" placeholder="$id$" @change="onUpdateWbComponent"></textarea-normal>
  </el-form>
</template>

<script setup lang="ts">
import { pushPages, pushPops } from '@/views/ts/'
import { GENERAL_ACTIVITY_TYPES } from '@/const/'
import { useWebControlsStore } from '@/store/web/controls'

const props = defineProps<{ 
  event: IEvent,
  index: number,
}>()

const event = props.event
const useWebControls = useWebControlsStore()


let wbData_: any
const wbData = computed(() => {
  try {
    wbData_ = useWebControls.currentControls![event.controlId] && useWebControls.currentControls![event.controlId].data
  } catch (error) {
    console.log("controlData.data null")
  }
  return wbData_
})
const onUpdateWbComponent = () => {
  useWebControls.updateWbComponent({ controlId: event.controlId, data: wbData_ })
}
</script>
